UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hiD9raa5CWQczSgPpmTGO0xemnLXINQvxoIEI+otAYk='
WHERE
key_id = 'c31dd32346d2093f3ed915e3247d2387147d115efedd889bac1c03a28a84177d'
AND (
token = 'hiD9raa5CWQczSgPpmTGO0xemnLXINQvxoIEI+otAYk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)